#ifndef XDIVA_COMMANDSERVER_P
#define XDIVA_COMMANDSERVER_P

#include "CommandServer.h"

#include <QtNetwork/QTcpServer>

#include <functional>

class CommandServer::Private: public QObject {
	Q_OBJECT
public:
	static std::unique_ptr< CommandServer, std::function< void ( CommandServer * ) > > self;
	static void destructor( CommandServer * pointer );

	explicit Private( CommandServer * owner );

public slots:
	void onNewConnection();
	void onSocketReadyRead();
	void onSocketDisconnected();
	void onSocketError( QAbstractSocket::SocketError socketError );

public:
	CommandServer * owner;
	QTcpServer * server;
	QTcpSocket * socket;
	std::map< QString, std::function< void ( const QStringList & ) > > commands;
	bool async;
};

#endif
